//
//  BK_OD_Address.m
//  bestkeep
//
//  Created by TOPTEAM on 2017/3/10.
//  Copyright © 2017年 utouu. All rights reserved.
//

#import "BK_OD_Address.h"
#import "BK_OD_Color.h"
/*
 * 地址栏
 */
@implementation BK_OD_Address


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self){
        [self initView];
    }
    return self;
}

- (void)initView{
    self.backgroundColor = [UIColor whiteColor];
    
    _ImgV_left=[[UIImageView alloc]init];
    _ImgV_left.backgroundColor=[UIColor clearColor];
    _ImgV_left.image=[UIImage imageNamed:@"订单详情-收货信息icon"];
    [self addSubview:_ImgV_left];
    [_ImgV_left mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).mas_offset(ApplicationBackGauge);
        make.height.mas_equalTo(14);
        make.width.mas_equalTo(12);
        make.centerY.equalTo(self.mas_centerY);
    }];
    
    
    /**
     * 收货msg
     */
    UILabel * lab_msg_peopleNum = [UILabel new];
    lab_msg_peopleNum.textColor = kOrderBlack1;
    lab_msg_peopleNum.numberOfLines = 1;
    lab_msg_peopleNum.backgroundColor = [UIColor clearColor];
    lab_msg_peopleNum.font = [UIFont systemFontOfSize:FONT_ORDER_Detail_ZHUTI];
    lab_msg_peopleNum.text = @"收货人：";
    [self addSubview:lab_msg_peopleNum];
    [lab_msg_peopleNum mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).mas_offset(WIDTH_LEFT);
        make.top.equalTo(self.mas_top).mas_offset(WIDTH_TOP);
    }];
    
    
    /**
     *  13088969520
     */
    _lab_phoneNum = [[UILabel alloc]initWithFrame:CGRectZero];
    _lab_phoneNum.textColor = kOrderBlack1;
    _lab_phoneNum.textAlignment = NSTextAlignmentRight;
    _lab_phoneNum.text = @"加载中...";
    _lab_phoneNum.backgroundColor = [UIColor clearColor];
    _lab_phoneNum.font = [UIFont systemFontOfSize:FONT_ORDER_Detail_ZHUTI+1];
    [self addSubview:_lab_phoneNum];
    [_lab_phoneNum mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.mas_right).mas_offset(-WIDTH_RIGHT);
        make.centerY.equalTo(lab_msg_peopleNum.mas_centerY);
        
    }];
    
    
    
    /**
     * 收货人
     */
    _lab_people = [[UILabel alloc]initWithFrame:CGRectZero];
    _lab_people.textColor = kOrderBlack1;
    _lab_people.text = @"加载中...";
    _lab_people.textAlignment = NSTextAlignmentLeft;
    _lab_people.font = [UIFont systemFontOfSize:FONT_ORDER_Detail_ZHUTI];
    [self addSubview:_lab_people];
    [_lab_people mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(lab_msg_peopleNum.mas_right).mas_offset(0);
        make.centerY.equalTo(lab_msg_peopleNum.mas_centerY);
        make.right.equalTo(_lab_phoneNum.mas_left);
        
        
    }];
    
    
    
    /**
     *  地址
     */
    _lab_address = [UILabel new];
    _lab_address.textColor = kOrderBlack1;
    _lab_address.numberOfLines = 2;
    _lab_address.backgroundColor = [UIColor clearColor];
    _lab_address.font = [UIFont systemFontOfSize:FONT_ORDER_Detail_ZHUTI];
    _lab_address.text = @"加载中...";
    [self addSubview:_lab_address];
    [_lab_address mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).mas_offset(WIDTH_LEFT);
        make.right.equalTo(self.mas_right).mas_offset(-WIDTH_RIGHT);
        make.top.equalTo(lab_msg_peopleNum.mas_bottom).mas_offset(10);
    }];
    
    
    
}
-(void)fillData:(id)data{
    BK_My_DetailOrder_CellModel *cellModel = data;
    
    BK_My_DetailOrder_Model *_centerModel = cellModel.OrderModel;
    
    if (_centerModel.deliver_name) {
        _lab_people.text = _centerModel.deliver_name;//人
    }
    if (_centerModel.phone) {
        NSString * str_Num=[NSString stringWithFormat:@"%@", _centerModel.phone];
        if (str_Num) {
            _lab_phoneNum.text = str_Num;//电话号码
        }
    }
    
    
    if (_centerModel.deliver_address) {
        
        NSString * str_address=[NSString stringWithFormat:@"收货地址：%@",_centerModel.deliver_address];
        // 调整行间距
        NSMutableAttributedString * Str_attribute = [[NSMutableAttributedString alloc] initWithString:str_address];
        NSMutableParagraphStyle * paragraphStyle = [[NSMutableParagraphStyle alloc] init];
        [paragraphStyle setLineSpacing:6];
        [Str_attribute addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [str_address length])];
        [self.lab_address setAttributedText:Str_attribute];
        [self.lab_address sizeToFit];
    }
    
    
    
}

@end
